package service;

import java.util.ArrayList;

import model.Player;
import model.Room;

public class Lobby {
	private ArrayList<Room> rooms=new ArrayList<Room>();
	private ArrayList<Player> players=new ArrayList<Player>();
	
	public ArrayList<Player> getPlayers() {
		return players;
	}
	public void setPlayers(ArrayList<Player> players) {
		this.players = players;
	}
	public boolean deleteRoom(int roomId){
		return false;
	}
	public void createRoom(Room room){
		rooms.add(room);
	}
	public boolean joinRoom(Room room,Player player){
		ArrayList<Player> players=room.getPlayers();
		if(players.size()<2){
			players.add(player);
			return true;
		}
		return false;
	}
	public Player find(long id){//cai tien sau
		for(Player p:players)
			if(p.getId()==id){
				return p;
			}
		return null;
	}
	public boolean checkExistPlayer(long id){//cai tien sau
		for(Player p:players)
			if(p.getId()==id){
				return true;
			}		
		return false;
	}

}
